#!/usr/bin/env python
# -*- coding: utf-8 -*-

from django.db import models
from dvadmin.utils.models import CoreModel


# Create your models here.


class Vehicle_info(CoreModel):
    """
    车辆信息表
    """
    vin = models.CharField(max_length=255, unique=True, verbose_name="vin")
    vehicle_type = models.IntegerField("车辆类型")
    vehicle_fence = models.CharField("电子围栏", max_length=60, default='', blank=True)
    vehicle_status = models.IntegerField("车辆在线状态")
    vehicle_motor = models.CharField("电机厂商", max_length=128)
    vehicle_battery = models.CharField("电池厂商", max_length=128)
    vehicle_motor_code = models.CharField("电机编号", max_length=128, default='', blank=True)
    vehicle_battery_code = models.CharField("电池编号", max_length=128, default='', blank=True)
    start_point = models.CharField("启点", max_length=60, default='', blank=True)
    end_point = models.CharField("终点", max_length=60, default='', blank=True)
    distance = models.IntegerField("启点-终点距离", default=0)

    class Meta:
        db_table = "vehicle_info"
        verbose_name = '车辆信息表'
        verbose_name_plural = verbose_name


class Vehicle_fence(CoreModel):
    """
    电子围栏
    """
    description = models.CharField(max_length=255, verbose_name='描述', default=True)
    modifier = models.CharField(max_length=255, verbose_name='修改人', default=True)
    dept_belong_id = models.CharField(max_length=255, verbose_name='数据归属部', default=True)
    update_datetime = models.DateTimeField(auto_now_add=True, verbose_name='更新时间')
    create_datetime = models.DateTimeField(auto_now_add=True, verbose_name='添加时间')

    fence_name = models.CharField(max_length=60, verbose_name='围栏名称')
    fence_alarm_type = models.CharField(max_length=60, verbose_name='围栏状态')
    status = models.IntegerField(default=1, verbose_name='是否启用(启用状态)')
    path = models.CharField(max_length=2048, verbose_name='围栏路径', default=True)

    # creator_id = models.BigIntegerField(verbose_name='创建人')

    class Meta:
        db_table = 'vehicle_fence'
        verbose_name = '电子围栏'
        verbose_name_plural = verbose_name


class Vehicle_fault_info(CoreModel):
    """
    故障表
    """
    description = models.CharField(max_length=255, verbose_name='描述', default='')
    modifier = models.CharField(max_length=255, verbose_name='修改人', default='')
    dept_belong_id = models.CharField(max_length=255, verbose_name='数据归属部', default='')
    update_datetime = models.DateTimeField(auto_now_add=True, verbose_name='更新时间')
    create_datetime = models.DateTimeField(auto_now_add=True, verbose_name='添加时间')
    fault_type = models.CharField(max_length=60, verbose_name='故障类型', default=True)
    fault_code = models.CharField(max_length=60, verbose_name='故障码', default='')
    fault_group = models.CharField(max_length=60, verbose_name='故障组', default='')
    fault_site = models.CharField(max_length=60, verbose_name='故障位', default='')
    fault_value = models.CharField(max_length=60, verbose_name='故障值', default='')
    is_warn = models.IntegerField(max_length=100, verbose_name='', default=0)
    fault_label = models.CharField(max_length=60, verbose_name='故障标签', default='')

    # creator_id = models.BigIntegerField(verbose_name='创建人')

    class Meta:
        db_table = 'vehicle_fault_info'
        verbose_name = '故障表'
        verbose_name_plural = verbose_name


class Vehicle_fault_log(CoreModel):
    """
    汽车故障日志
    """
    description = models.CharField(max_length=255, verbose_name='描述', default=True)
    modifier = models.CharField(max_length=255, verbose_name='修改人', default=True)
    dept_belong_id = models.CharField(max_length=255, verbose_name='数据归属部', default=True)
    update_datetime = models.DateTimeField(auto_now_add=True, verbose_name='更新时间')
    create_datetime = models.DateTimeField(auto_now_add=True, verbose_name='添加时间')
    vin = models.CharField(max_length=255, verbose_name='车辆唯一编码', default=True)
    fault_code = models.CharField(max_length=60, verbose_name='故障码', default=True)
    log_status = models.CharField(max_length=60, verbose_name='故障状态', default=True)
    start_time = models.DateTimeField(auto_now_add=True)
    end_time = models.DateTimeField(auto_now_add=True)
    process_by = models.CharField(max_length=60, verbose_name='处理人', default=True)
    process_time = models.DateTimeField(auto_now_add=True, verbose_name='处理时间')

    class Meta:
        db_table = 'vehicle_fault_log'
        verbose_name = '汽车故障日志'
        verbose_name_plural = verbose_name


class Vehicle_move_info(CoreModel):
    """
    车辆行驶记录
    """

    description = models.CharField(verbose_name='描述', max_length=255)
    modifier = models.CharField(verbose_name='修改人', max_length=255)
    dept_belong_id = models.CharField(verbose_name='数据归属部', max_length=255)
    update_datetime = models.DateTimeField(auto_now_add=True)
    create_datetime = models.DateTimeField(auto_now_add=True)
    vehicle_vin = models.CharField(verbose_name='车辆编码', max_length=255)
    start_time = models.DateTimeField(auto_now_add=True, verbose_name='行程开始时间')
    end_time = models.DateTimeField(auto_now_add=True, verbose_name='行程结束时间')
    # creator_id = models.BigIntegerField(verbose_name='创建人')
    score = models.IntegerField(verbose_name='行程打分')
    offset = models.CharField(verbose_name='行程偏移量', max_length=255)

    class Meta:
        db_table = 'vehicle_move_info'
        verbose_name = '车辆行驶记录'
        verbose_name_plural = verbose_name
